/*    */ package com.zimbra.cs.util.tnef.mapi;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import java.io.PrintStream;
/*    */ import java.util.TimeZone;
/*    */ import net.freeutils.tnef.RawInputStream;
/*    */ import org.junit.Assert;
/*    */ import org.junit.Test;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TestTnefTimeZone
/*    */ {
/*    */   @Test
/*    */   public void testTnefTimeZoneFromIntIndex()
/*    */     throws IOException
/*    */   {
/* 31 */     TimeZone tz = null;
/*    */     
/* 33 */     tz = TnefTimeZone.getTimeZone(13, true, null);
/* 34 */     Assert.assertFalse(tz == null);
/* 35 */     Assert.assertTrue(tz.getRawOffset() == -28800000);
/* 36 */     Assert.assertTrue(tz.getDSTSavings() == 3600000);
/*    */     
/* 38 */     tz = TnefTimeZone.getTimeZone(31, true, null);
/* 39 */     Assert.assertFalse(tz == null);
/* 40 */     Assert.assertTrue(tz.getRawOffset() == 0);
/* 41 */     Assert.assertTrue(tz.getDSTSavings() == 0);
/*    */     
/* 43 */     tz = TnefTimeZone.getTimeZone(60, true, null);
/* 44 */     Assert.assertTrue(tz == null);
/*    */     
/* 46 */     tz = TnefTimeZone.getTimeZone(24, false, null);
/* 47 */     Assert.assertFalse(tz == null);
/* 48 */     Assert.assertTrue(tz.getID().equals("Asia/Dubai"));
/*    */   }
/*    */   
/*    */   @Test
/*    */   public void testLittleEndianByteArrayToIntConversions()
/*    */   {
/* 54 */     int value = 40067898;
/* 55 */     byte[] leByteArray = intToleByteArray(value);
/* 56 */     Assert.assertTrue(leByteArrayToInt(leByteArray) == value);
/*    */   }
/*    */   
/*    */   @Test
/*    */   public void testTnefTimeZoneFromInputStream() throws IOException {
/* 61 */     TimeZone tz = null;
/* 62 */     RawInputStream ris = null;
/*    */     
/* 64 */     ris = new RawInputStream(intToleByteArray(13), 0L, 4L);
/* 65 */     tz = TnefTimeZone.getTimeZone(ris);
/* 66 */     Assert.assertFalse(tz == null);
/* 67 */     Assert.assertTrue(tz.getRawOffset() == -28800000);
/* 68 */     Assert.assertTrue(tz.getDSTSavings() == 3600000);
/*    */     
/*    */ 
/* 71 */     ris = new RawInputStream(new byte[] { 13, 0, 0, Byte.MIN_VALUE }, 0L, 4L);
/* 72 */     tz = TnefTimeZone.getTimeZone(ris);
/* 73 */     Assert.assertFalse(tz == null);
/* 74 */     Assert.assertTrue(tz.getRawOffset() == -28800000);
/* 75 */     Assert.assertTrue(tz.getID().equals("Etc/GMT+8"));
/*    */   }
/*    */   
/*    */   private static final byte[] intToleByteArray(int value) {
/* 79 */     return new byte[] { (byte)value, (byte)(value >>> 8), (byte)(value >>> 16), (byte)(value >>> 24) };
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   private static final int leByteArrayToInt(byte[] data)
/*    */   {
/* 87 */     return data[3] << 24 | data[2] << 16 | data[1] << 8 | data[0];
/*    */   }
/*    */   
/*    */   public static void main(String[] args) {
/* 91 */     for (int i = 0; i < 60; i++) {
/*    */       try {
/* 93 */         System.out.println("Index " + i + ": " + TnefTimeZone.getTimeZone(i, true, null));
/*    */       }
/*    */       catch (IOException e) {
/* 96 */         e.printStackTrace();
/*    */       }
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/util/tnef/mapi/TestTnefTimeZone.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */